<script setup lang="ts">
import {ref} from "vue";
import {Myappointment} from "@/http/Personal center";
import {useCounterStore} from "@/stores/counter";

let baseUrl = 'http://192.168.5.120:8090'


const onClickLeft = () => history.back();
const iddata=useCounterStore()
const idinfo=ref('')
idinfo.value=iddata.userInfo.id

// console.log(iddata.userInfo.id)

const data=ref({
    studentId: idinfo.value,
    pageNum: 1,
    pageSize: 100
})
const list=ref({})
Myappointment(data.value).then(res=>{
    // console.log(res)
    if (res.code==200){
        list.value=res.rows
    }


})
function click(item){
    iddata.consultid=item.id
    // console.log(iddata.consultid)
}
</script>

<template>
<div>
    <van-nav-bar
            left-text="我的咨询"
            left-arrow
            @click-left="onClickLeft"
    />
    <router-link to="/ConsultationDetails" id="woend" >
    <div class="tation" v-for="item in list" :key="item.id" @click="click(item)">
        <div class="top">
        <div class="pictie">
            <img :src="baseUrl+item.psyTeacher.avatar" alt="" id="woes" >
        </div>
        <div class="time">
            <span>{{item.psyTeacher.name}}</span>
            <div class="times">
                <span>{{item.psyScheduling.date}}</span>
                <span>{{item.psyScheduling.startTime}}-{{item.psyScheduling.endTime}}</span>
            </div>
        </div>
            <div class="stap" style="background-color: #e8d3ff;color: #7246c5"
                 v-if="item.status==0">
                 待开始
            </div>
            <div class="stap" style="background-color: #58e043;color: #ffffff"
                 v-if="item.status==1">
                进行中
            </div>
            <div class="stap" style="background-color: #077ac0;color: #ffffff"
                 v-if="item.status==2">
                已结束
            </div>
            <div class="stap" style="background-color: #d9ad34;color: #ffffff"
                 v-if="item.status==3">
                已取消
            </div>
        </div>
        <div class="bottom">
            <div class="left">
                <van-icon name="comment" />
                <div>
                   {{item.mode}}
                </div>
            </div>
            <div class="right">
                {{item.psyTeacher.location}}
            </div>
        </div>
    </div>
    </router-link>
</div>
</template>

<style scoped lang="less">
#woend{
    color: black;
    .tation{
        width: 90%;
        height: 100px;
        margin: 10px auto;
        padding: 10px;
        box-sizing: border-box;
        background-color: white;
        .top{
            display: flex;
            justify-content: space-between;
            .pictie{
                width: 16%;
                height:50px;
                #woes{
                    width: 100%;
                    height: 100%;
                    border-radius: 5px;
                }
            }
            .time{
                width: 50%;
                height: 50px;
                span{
                    font-size: 14px;
                }
                .times{
                    span{
                        font-size: 14px;
                        margin-right: 6px;
                    }
                }
            }
            .stap{
                width: 75px;
                height: 20px;
                font-size: 14px;
                text-align: center;
                line-height: 20px;
                margin-right: -10px;
                border-radius: 10px 0 0 10px;
                //background-color: #afabab;
            }
        }
        .bottom{
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            .left{
                display: flex;

                div{
                    font-size: 14px;
                }
            }
            .right{
                font-size: 14px;
            }
        }
        :deep(.van-icon){
            top:3px;
            margin-right: 5px;
        }
    }
}

</style>